package org.fujay.langchain4jserver.domain.application.event;

import org.fujay.langchain4jserver.domain.application.vo.AppConfigSnapshot;
import org.fujay.langchain4jserver.domain.application.vo.AppId;
import org.fujay.langchain4jserver.domain.application.vo.Version;
import org.springframework.context.ApplicationEvent;

/**
 * Domain Event indicating the configuration of an Application has been rolled back.
 */
public class AppConfigRolledBackEvent extends ApplicationEvent {

    private final AppId appId;
    private final Version rolledBackToVersion; // The version that was rolled back to
    private final Version newCurrentVersion; // The new version created after rollback
    private final AppConfigSnapshot currentConfigSnapshot; // The config after rollback

    /**
     * Create a new AppConfigRolledBackEvent.
     *
     * @param source                the component that published the event
     * @param appId                 the ID of the application
     * @param rolledBackToVersion   the historical version that was reinstated
     * @param newCurrentVersion     the new version identifier created for this rollback action
     * @param currentConfigSnapshot the configuration snapshot after the rollback
     */
    public AppConfigRolledBackEvent(
            Object source,
            AppId appId,
            Version rolledBackToVersion,
            Version newCurrentVersion,
            AppConfigSnapshot currentConfigSnapshot) {
        super(source);
        this.appId = appId;
        this.rolledBackToVersion = rolledBackToVersion;
        this.newCurrentVersion = newCurrentVersion;
        this.currentConfigSnapshot = currentConfigSnapshot;
    }

    // Getters
    public AppId getAppId() {
        return appId;
    }

    public Version getRolledBackToVersion() {
        return rolledBackToVersion;
    }

    public Version getNewCurrentVersion() {
        return newCurrentVersion;
    }

    public AppConfigSnapshot getCurrentConfigSnapshot() {
        return currentConfigSnapshot;
    }
}
